Skip to content

Fix dynamic LOOP WHERE with IN - #1775

Merged
larshp merged 4 commits into
mainfrom
copilot/dynamic-loop-where-in
Jul 30, 2026
Merged

Fix dynamic LOOP WHERE with IN#1775
larshp merged 4 commits into
mainfrom
copilot/dynamic-loop-where-in

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Dynamic LOOP AT ... WHERE (cond) only handled IN in a narrow lower-case form. Upper case conditions silently matched nothing (or crashed), and NOT IN produced invalid JavaScript.

DATA range TYPE RANGE OF i.
DATA dynamic TYPE string.

dynamic = 'FIELD IN RANGE'.      " -> TypeError, operand resolved to undefined
dynamic = 'field not in range'.  " -> SyntaxError: Unexpected identifier 'range'

LOOP AT tab INTO row WHERE (dynamic).
ENDLOOP.

Changes in packages/runtime/src/statements/loop.ts (dynamicToWhere):

  • Case insensitive operands — the right hand operand is lower cased before evaluate(...), matching the lower case identifiers emitted by the transpiler. ABAP conditions are typically written in upper case.
  • NOT IN — comparator regex now matches NOT IN as one token and emits !abap.compare.in(...). Previously it parsed as comparator not with operand in, leaving a dangling identifier in the evaluated expression.
  • Field symbol operandFIELD IN <RANGE> resolves to evaluate("fs_range_").getPointer(), so the range table behind the field symbol is passed to abap.compare.in.

Tests added in test/statements/loop.ts covering upper case IN, NOT IN, and a field symbol range.

Copilot AI linked an issue Jul 30, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix dynamic loop where IN issue Fix dynamic LOOP WHERE with IN Jul 30, 2026
Copilot AI requested a review from larshp July 30, 2026 11:09
@github-actions

Copy link
Copy Markdown

Regression test results:

Repository Result Runtime
abap-openapi/abap-openapi 🟢 15s
abapGit/abapGit 🟢 14s
heliconialabs/abap-opentelemetry 🟢 5s
heliconialabs/abap-protobuf 🟢 6s
larshp/abap-advent-2020 🟢 5s
larshp/abap-wasm 🟢 4s
larshp/abapNTLM 🟢 5s
larshp/abapPGP 🟢 116s
oisee/zork-abap 🟢 6s
open-abap/open-abap-core 🟢 6s
open-abap/open-abap-gui 🟢 5s
open-abap/open-abap-jobs 🟢 13s
open-abap/open-abap-lock 🟢 11s
open-abap/open-abap-odata 🟢 7s
open-abap/open-table-maintenance 🟢 13s
SAP/abap-file-formats-tools 🟢 15s
Sumu-Ning/AES 🟢 5s

Performance test results:

Performance Before After Delta
1: APPEND and DELETE 700ms 713ms 13 🟢
2: READ TABLE, table_line 888ms 909ms 21 🟢
3: LOOP USING KEY 944ms 945ms 1 🟢
4: Copy, same sorting 210ms 208ms -2 🟢
5: Copy, becomes sorted 48ms 46ms -2 🟢
6: INSERT INDEX 1 814ms 832ms 18 🟢
7: APPEND matching types 436ms 307ms -129 🟢
8: READ TABLE BINARY SEARCH 53ms 51ms -2 🟢
9: INSERT INTO TABLE hashed 278ms 265ms -13 🟢
10: DELETE ADJACENT 1095ms 1060ms -35 🟢
11: READ WITH TABLE KEY HASHED 197ms 197ms 0 🟢
12: READ WITH KEY HASHED, primary 260ms 260ms 0 🟢
13: INSERT INTO TABLE standard 28ms 30ms 2 🟢
14: Constant characters 58ms 56ms -2 🟢
15: Compare characters 98ms 100ms 2 🟢
16: Method number 5 🎶 644ms 662ms 18 🟢
17: Substring and find negative 185ms 194ms 9 🟢
18: CO compare 147ms 142ms -5 🟢
19: Call method, compatible structure 86ms 88ms 2 🟢
20: Call method, identical structure 15ms 15ms 0 🟢
21: CASE many char constants 313ms 318ms 5 🟢
22: READ TABLE WITH KEY secondary 33ms 39ms 6 🟢
23: CASE many int constants 325ms 328ms 3 🟢
24: Copy table contents 186ms 195ms 9 🟢
25: READ TABLE, not found 18ms 20ms 2 🟢
26: REPLACE OCCURRENCES, simple 101ms 99ms -2 🟢
27: READ TABLE, building hash 54ms 55ms 1 🟢
28: CONCATENATE 2ms 2ms 0 🟢
29: Write Hex to Hex via offset 861ms 820ms -41 🟢
30: Get Hex from Hex via offset 9ms 7ms -2 🟢
31: SET BIT hex 940ms 938ms -2 🟢
32: GET BIT hex 733ms 743ms 10 🟢
33: Compare Hex 679ms 691ms 12 🟢
34: Basic CONCATENATE 56ms 56ms 0 🟢
35: gt 303ms 303ms 0 🟢
36: CLEAR char 211ms 194ms -17 🟢
37: CLEAR numc 181ms 178ms -3 🟢
38: Structure copy and APPEND 616ms 619ms 3 🟢
39: eq int 1214ms 1225ms 11 🟢
40: eq string 1084ms 1132ms 48 🟢
41: eq char, different lengths 166ms 165ms -1 🟢
42: eq int with numc 163ms 164ms 1 🟢

Updated: 2026-07-30T11:24:27.124Z

SHA: 8d70881

@larshp
larshp marked this pull request as ready for review July 30, 2026 11:27
@larshp
larshp enabled auto-merge (squash) July 30, 2026 11:27
@larshp
larshp merged commit 19b1389 into main Jul 30, 2026
4 checks passed
@larshp
larshp deleted the copilot/dynamic-loop-where-in branch July 30, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

dynamic loop where IN

2 participants